jQuery(document).ready(function() {

        // Main menu hover
        jQuery('#header ul li').hover(
            function(){
                jQuery(this).children('ul').fadeIn('fast');
            },
            function(){
                jQuery(this).children('ul').fadeOut('fast');
            }
        );

        //set active link
        function set_active(ch_no)
        {
            jQuery('#header ul li:nth-child('+ch_no+')').addClass('active')
        }

        switch(page)
        {
            case 'home': set_active(1); break;
            case 'about': set_active(2); break;
            case 'ressidance': set_active(3); break;
            case 'gallery': set_active(4); break;
            case 'contact': set_active(5); break;
        }

        var images = [];

        switch(page){
            case 'home':
                images = [
                    {image : base_url+'assets/img/fullscreen/09.jpg', title : 'IT Montenengro'}                                
                ];
                break;
            case 'news':
                images = [
                    {image : base_url+'assets/img/fullscreen/09.jpg', title : 'IT Montenengro'}                                
                ];
                break;
            case 'rentacar':
                images = [
                    {image : base_url+'assets/img/fullscreen/01.jpg', title : 'IT Montenengro'},
                    {image : base_url+'assets/img/fullscreen/03.jpg', title : 'IT Montenengro'}
                ];
                break;
            case 'excursions':
                images = [
                    {image : base_url+'assets/img/fullscreen/05.jpg', title : 'IT Montenengro'},
                    {image : base_url+'assets/img/fullscreen/07.jpg', title : 'IT Montenengro'},
                    {image : base_url+'assets/img/fullscreen/02.jpg', title : 'IT Montenengro'}
                ];
                break;
            case 'accommodations':
                images = [
                    {image : base_url+'assets/img/fullscreen/06.jpg', title : 'IT Montenengro'}
                ];
                break;
            case 'cms':
                images = [
                    {image : base_url+'assets/img/fullscreen/08.jpg', title : 'IT Montenengro'}
                ];
                break;
            case 'terms':
                images = [
                    {image : base_url+'assets/img/fullscreen/04.jpg', title : 'IT Montenengro'}
                ];
                break;
        }

        jQuery.supersized({

                // Functionality
                start_slide             :   1,            // Start slide (0 is random)
                autoplay                :   1,
                stop_loop               :   0,
                new_window              :   1,            // Image links open in new window/tab
                image_protect           :   1,            // Disables image dragging and right click with Javascript
                slideshow               :   1,
                random                  :   0,
                slide_interval          :   7000,


                transition              :   1,             // 0-None, 1-Fade, 2-Slide Top, 3-Slide Right, 4-Slide Bottom, 5-Slide Left, 6-Carousel Right, 7-Carousel Left
                transition_speed        :   1000,          // Speed of transition 
                performance             :   1,     // 0-Normal, 1-Hybrid speed/quality, 2-Optimizes image quality, 3-Optimizes transition speed // (Only works for Firefox/IE, not Webkit) 

                // Size & Position                           
                min_width               :   0,            // Min width allowed (in pixels)
                min_height              :   0,            // Min height allowed (in pixels)
                vertical_center         :   0,            // Vertically center background
                horizontal_center       :   0,            // Horizontally center background
                fit_always              :   0,            // Image will never exceed browser width or height (Ignores min. dimensions)
                fit_portrait            :   0,            // Portrait images will not exceed browser height
                fit_landscape           :   0,            // Landscape images will not exceed browser width

                // Components
                slides                     :      images

        });

        //CMS Pro Gallery
        //console.log('h1'+jQuery(".contect-text h1").length)
        //console.log('pre'+jQuery(".contect-text pre").length)
        if (jQuery(".contect-text h1").length > 1){
            jQuery(jQuery('#to_remove').html()).insertBefore('.contect-text h1:eq(1)');
            jQuery('#to_remove').remove();
        } else if(jQuery('.contect-text pre').length > 0){
            jQuery(jQuery('#to_remove').html()).insertBefore('.contect-text pre:eq(0)');
            jQuery('#to_remove').remove(); 
        }else{
            jQuery('.contect-text').append(jQuery('#to_remove').html());
            jQuery('#to_remove').remove(); 
        }

        //scroller plugin
        //plugin
        jQuery.fn.topLink = function(settings) {
            settings = jQuery.extend({
                    min: 1,
                    fadeSpeed: 200,
                    ieOffset: 50
                }, settings);
            return this.each(function() {
                    //listen for scroll
                    var el = jQuery(this);
                    el.css('display','none'); //in case the user forgot
                    jQuery(window).scroll(function() {
                            //stupid IE hack
                            if(!jQuery.support.hrefNormalized) {
                                el.css({
                                        'position': 'absolute',
                                        'top': jQuery(window).scrollTop() + jQuery(window).height() - settings.ieOffset
                                });
                            }
                            if(jQuery(window).scrollTop() >= settings.min)
                                {
                                el.fadeIn(settings.fadeSpeed);
                            }
                            else
                                {
                                el.fadeOut(settings.fadeSpeed);
                            }
                    });
            });
        };

        //usage w/ smoothscroll
        //set the link
        jQuery('#top-link').topLink({
                min: 400,
                fadeSpeed: 500
        });
        //smoothscroll
        jQuery('#top-link').click(function(e) {
                e.preventDefault();
                jQuery.scrollTo(0,300);
        });


});